# -*- coding: utf-8 -*-

# @File  : utill.py
# @Author: Lomo
# @Site  : lomo.space
# @Date  : 2019-12-03
# @Desc  : Utils


import inspect
import random


class Utils():
    @staticmethod
    def get_function_name():
        return inspect.stack()[1][3]

    @staticmethod
    def chinese_content(length):
        """
        随机生成一段文本(大概率生成的是繁体) 注: 在unicode码中,汉字的范围是(0x4E00, 9FBF)
        :param length: 字符长度
        :return: string, 一串汉字字符
        """
        arr = []
        for i in range(length):
            arr.append(chr(random.randint(0x4e00, 0x9fbf)))
        return ''.join(arr)

    @staticmethod
    def phone_number(env='dev'):
        """
        自动生成 11 位手机号
        :param env: 环境(只有 dev 环境才可以使用 19开头的手机号)
        :return: string, phone number
        """
        second_number = [3, 4, 5, 6, 7, 8, 9]
        second_number = second_number[random.randint(0, 6)] if env == 'dev' else second_number[random.randint(0, 5)]
        third_number = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][random.randint(0, 9)]
        last = random.randint(9999999, 100000000)  # 后八位

        return "1{0}{1}{2}".format(second_number, third_number, last)




